<!DOCTYPE html>
<html>
<head>
    <title>模块菜单</title>
    <include file='public/head'>
</head>
<body>
    <div class="wrap js-check-wrap">
        <table class="table table-bordered table-hover">
            <thead>
                <tr class="theader">
                	<td width="50">ID</td>
                	<td width="350">名称</td>
                    <th width="100">排序</th>
                    <th>app</th>
                    <th>controller</th>
                    <th>action</th>
                    <th width="120">类型</th>
                    <th width="100">左侧显示</th>
                    <th>版本  <a class="btn btn-primary btn-xs btn-edit" onclick="changBtn(this);" >修改</a><a class="btn btn-info btn-xs btn-return" onclick="changBtns(this);" style="display: none;" >返回</a> </th>
                </tr>
            </thead>
            
            <tbody class="table-body">
            	{$tableStr|default=''}
            </tbody>

            <tbody class="table-body-edit" style="display: none;">
            	{$editStr|default=''}
            </tbody>

        </table>
    </div>
<include file='public/scripts'>
<script src="__STATIC__/js/layer/layer.js"></script>
<script src="__STATIC__/js/custom/custom.js"></script>

<script>
var isEdit = false;
var changBtn = function( _this ){
	isEdit = true;
	$('.table-body-edit').show();
	$('.table-body').hide();
	$(_this).hide();
	$('.btn-return').show();
}
var changBtns = function( _this ){
	isEdit = false;
	$('.table-body').show();
	$('.table-body-edit').hide();
	$(_this).hide();
	$('.btn-edit').show();
}

//更新数据
var updateData = function(){
	if( false == isEdit ) return [];
	var trs = $( '.table-body-edit .x-name' ).parents('tr');
	var obj = [];
	$.each( trs , function(){
		let tr = $(this);
		var tmp = {};
		tmp ['id'] = $(this).find('td:eq(0)').text();
		tmp ['name'] = $(tr).find( 'input[name=name]' ).val(); 
		tmp ['list_order'] = $(tr).find( 'input[name=list_order]' ).val(); 
		tmp ['app'] = $(tr).find( 'input[name=app]' ).val(); 
		tmp ['controller'] = $(tr).find( 'input[name=controller]' ).val(); 
		tmp ['action'] = $(tr).find( 'input[name=action]' ).val();
		tmp ['status'] = $(tr).find( 'select[name=status]' ).val(); 
		tmp ['type'] = $(tr).find( 'select[name=type]' ).val(); 
		obj.push( tmp );
	});
	return obj;
}
</script>
</body>
</html>